public class 买卖股票的最佳时机 {
    public int maxProfit(int[] prices) {
        //记录最小值
        int minPrice = Integer.MAX_VALUE;
        //返回值
        int ret = 0;
        //每次更新最小值, 贪心
        for(int i = 0;i < prices.length;i++){
            minPrice = Math.min(prices[i],minPrice);
            ret = Math.max(prices[i] - minPrice,ret);
        }
        return ret;
    }
}
